#!/bin/bash
USERNAME="user"
PASSWORD="pass"

#---------------------------------------------------------------------
LOGFILE="/tmp/zruijie.log"

zruijie -u "$USERNAME" -p "$PASSWORD" --dhcp -b "$@" 2>&1|tee "$LOGFILE"
#cat zrj.txt|tee "$LOGFILE"

program_err=`sed -n -e '/^@@ERROR/p' $LOGFILE`
server_info=`sed -n -e '/^>>Server/p' $LOGFILE`
account_info=`sed -n -e '/^>>Account/{N;s/\n//;p}' $LOGFILE`
rm $LOGFILE
notify(){
    notify-send "锐捷" "$1";
    if [ $? -eq 127 ]; then
        echo "\`notify-send' not installed."
        echo "$1"
    fi
}

for msg in "$program_err" "$server_info" "$account_info"; do
    if [[ $msg ]]; then
        notify "${msg##>>}"
    fi
done


